package com.example.config;

import io.minio.MinioClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class MinioConfiguration {

    @Value("${spring.minio.endpoint}")
    String endpoint;
    @Value("${spring.minio.username}")
    String username;
    @Value("${spring.minio.password}")
    String password;

    //配置minio客户端
    @Bean
    public MinioClient minioClient(){
      log.info("init minio client...");
      return MinioClient.builder()
              .endpoint(endpoint)
//              也可以使用配置的ak和sk
              .credentials(username,password)
              .build();
    }
}
